home *** CD-ROM | disk | FTP | other *** search
- ;filename HICOPY2.ASM - file to test copying of a block of
- ; code into the HMA from conventional memory, then branch
- ; to, execute and return from that code.
- ;Released into the Public Domain - November/88 by D. Roy
-
- CODE SEGMENT PARA PUBLIC 'CODE'
- ASSUME CS:CODE, DS:CODE ;-----------------------------;
- ORG 100H ;COM file format! Remember to ;
- ; use EXE2BIN ;
- START: ;-----------------------------;
- JMP XMSTEST
- ;data area
- COPY_CODE LABEL BYTE
- LEA DX,HI_MSG
- MOV AH,9
- INT 21h
- RETF
- HI_MSG DB 'Hello, World! HMA here...$'
- COPY_END LABEL BYTE
- XMSControl DD ?
- HMAStart DD ?
- NODRIVER_MSG DB 'No XMS driver installed!...$'
- BADVERS_MSG DB 'Requires Version 2.X XMS Driver!...$'
- NOHMA_MSG DB 'HMA denied!...$'
- OKHMA_MSG DB 'HMA successfully allocated!',10,13,'$'
- NOA20_MSG DB 'A20 Line not enabled!$'
- A20LINE_MSG DB 'A20 Line enabled...',10,13,'$'
- COPY_MSG DB 'Copying...$'
- COMPLETE_MSG DB 'complete.',10,13,'$'
-
- ;code area
- XMSTEST:
- MOV AX,4300h
- INT 2Fh
- CMP AL,80h
- LEA DX,NODRIVER_MSG
- JE XM1
- JMP ERROR_EXIT
- ;get address of control driver function
- XM1: MOV AX,4310h
- INT 2Fh
- MOV WORD PTR [XMSControl],BX
- MOV WORD PTR [XMSControl+2],ES
- ;hard load the HMA starting address (doesn't change)
- MOV WORD PTR [HMAStart],0010h
- MOV WORD PTR [HMAStart+2],0FFFFh
- ;get driver's version number
- MOV AH,00
- CALL [XMSControl]
- CMP AH,2
- LEA DX,BADVERS_MSG
- JNE ERROR_EXIT
- ;now request an HMA
- MOV AH,01
- MOV DX,0FFFFh ;since we're an application
- CALL [XMSControl]
- ;and verify allocation
- OR AX,AX
- LEA DX,NOHMA_MSG
- JE ERROR_EXIT
- LEA DX,OKHMA_MSG
- CALL WRITE_STRING
- ;now, enable the A20 address line
- MOV AH,3
- CALL [XMSControl]
- OR AX,AX
- LEA DX,NOA20_MSG
- JE ERROR_EXIT
- LEA DX,A20LINE_MSG
- CALL WRITE_STRING
- ;OK, let's do a block copy to the HMA
- LEA DX,COPY_MSG ;say what we're up to
- CALL WRITE_STRING
- CLD ;direction forward
- PUSH SI ;save what we're using
- PUSH DI
- PUSH ES
- MOV CX,OFFSET COPY_END ;end of data
- SUB CX,OFFSET COPY_CODE ;start of data
- SHR CX,1 ;divide by 2 for words
- LEA SI,COPY_CODE ;point to source
- MOV BX,0FFFFh ;segment of HMA
- MOV ES,BX ; into ES
- MOV DI,0010h ;point to offset
- L1: MOVSW ;moving words is faster
- LOOP L1 ;loop until done
- POP ES ;housecleaning
- POP DI
- POP SI
- ;and signal completion
- LEA DX,COMPLETE_MSG
- CALL WRITE_STRING
- ;activate HMA resident code
- CALL [HMAStart]
- ;finally, disable the A20 address line
- MOV AH,4
- CALL [XMSControl]
- ;and release the HMA
- MOV AH,2
- CALL [XMSControl]
- JMP EXIT
- ERROR_EXIT:
- CALL WRITE_STRING
- EXIT: INT 20h
-
- ;-- subroutines ---------------
-
- WRITE_STRING PROC NEAR
- MOV AH,9
- INT 21h
- RET
- WRITE_STRING ENDP
-
- CODE ENDS
- END START